/* OnLoad
 * ****************************************************************************/
/* Actions-Catch
 * ****************************************************************************/
$('#agregarImagen').click(agregarImagenMenu);
$('#consultarImagen').click(consultarImagenMenu);
/* Interface-Loaders
 * ****************************************************************************/
function agregarImagenMenu(){
    $('#center').load('Modulo2/agregarImagen.jsp');
}
function consultarImagenMenu(){
    $('#center').load('Modulo2/consultarImagen.jsp');
}
/* Actions
 * ****************************************************************************/
function listEdificios(){
    $.ajax({
        url: "listaEdificioAction.do",
        type: "GET",
        dataType: 'json',
        success: function(data) {
            prev = "";
            $.each(data.Edificio, function(i,item){
                var string = "<option value='"+item.edificio+"' >"+item.edificio+"</option>";
                $('#edificios').prepend(string);
                prev = item.edificio;
            });
        }
    });
}
function getPisos(edificio){
    $.ajax({
        type: "GET",
        url: "getPisos.do?edificio="+edificio,
        dataType: 'json',
        success: processGetPisos
    });
    return false;
}
function consultarExtintores(ed,ps){
    $.ajax({
        url: "consultarExtintores.do",
        data: {
            'edificio': ed,
            'piso': ps
        },
        type: "GET",
        dataType: 'json',
        success: function(data) {
            $.each(data.extintores, function(i,item){
                coord = item.coordenadas.split(',');
                setIcon(coord[0], coord[1]);
            });
        }
    });
}
/* Process-Actions
     * ****************************************************************************/
function processGetPisos(answer){
    if(answer.pisos){
        ps = "";
        $.each(answer.pisos, function(index,value){
            params = "'"+answer.edificio+"','"+value.id_piso+"','"+value.ruta_plano+"'";
            action = "\"javascript:loadPlano("+params+");\""
            if(value.id_piso > 0)
                ps += "   |   <a onclick="+action+">"+value.id_piso+"</a>";
            else
                ps = "<a onclick="+action+">PB</a>" + ps;
        });
        $('#pisos').html(ps);
        $('#backUSB').toggleClass('muestra');
    }
}






    /*
 function customizeControls(){
    type = $(this).attr('id');
    $('#controlMapForm').load('Modulo2/Templates/control'+type+'.jsp');
   
}
     */


    /*------------------------------------------------------------
$('#mapRange').live('change',function(){
    fillDates();
});


function fillDates(){
    today = new Date();
    switch ($('#mapRange').val()) {
        case 'hoy':
            day = today.getDay();
            first = today.getDate()+"-"+today.getMonth()+"-"+today.getUTCFullYear();
            $('#desdeControl').val(first);
            $('#hastaControl').val(first);
            break;
        case 'semana':
            day = today.getDay();
            first = today.getDate()-day+1+"-"+today.getMonth()+"-"+today.getUTCFullYear();
            last = today.getDate()+7-day+"-"+today.getMonth()+"-"+today.getUTCFullYear();
            $('#desdeControl').val(first);
            $('#hastaControl').val(last);
            break;
        case 'mes':
            day = today.getUTCDate();
            first = today.getDate()-day+1+"-"+today.getMonth()+"-"+today.getUTCFullYear();
            last = today.getDate()+30-day+"-"+today.getMonth()+"-"+today.getUTCFullYear();
            $('#desdeControl').val(first);
            $('#hastaControl').val(last);
            break;
        default:
            break;
    }
}

function replaceAll( text, busca, reemplaza ){
    while (text.toString().indexOf(busca) != -1)
        text = text.toString().replace(busca,reemplaza);
    return text;
}


DCHP 159.90.91.1
     */
